home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue61 / Clinic / IDESnooperU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-06-29  |  2.3 KB  |  99 lines

  1. unit IDESnooperU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   AppEvnts, StdCtrls;
  8.  
  9. type
  10.   TActionTrappingForm = class(TForm)
  11.     lstActions: TListBox;
  12.     chkOn: TCheckBox;
  13.     btnClear: TButton;
  14.     btnProd: TButton;
  15.     chkSkipHints: TCheckBox;
  16.     btnTestShortcut: TButton;
  17.     ApplicationEvents: TApplicationEvents;
  18.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  19.     procedure btnClearClick(Sender: TObject);
  20.     procedure btnProdClick(Sender: TObject);
  21.     procedure btnTestShortcutClick(Sender: TObject);
  22.     procedure ApplicationEventsActionExecute(Action: TBasicAction;
  23.       var Handled: Boolean);
  24.   end;
  25.  
  26. procedure Register;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32. uses
  33.   Menus, StdActns;
  34.  
  35. var
  36.   ActionTrappingForm: TActionTrappingForm;
  37.  
  38. procedure TActionTrappingForm.FormClose(Sender: TObject; var Action: TCloseAction);
  39. begin
  40.   Action := caNone
  41. end;
  42.  
  43. procedure TActionTrappingForm.btnClearClick(Sender: TObject);
  44. begin
  45.   lstActions.Items.Clear
  46. end;
  47.  
  48. procedure TActionTrappingForm.btnProdClick(Sender: TObject);
  49. var
  50.   Form: TCustomForm;
  51. begin
  52.   //Locate the code editor
  53.   Form := Application.FindComponent('EditWindow_0') as TCustomForm;
  54.   if Assigned(Form) then
  55.   begin
  56.     //Bring it to the foreground
  57.     Form.BringToFront;
  58.     //Reproduce the keystroke
  59.     Keybd_Event(0, $7F, 0, 0)
  60.   end;
  61. end;
  62.  
  63. procedure TActionTrappingForm.btnTestShortcutClick(Sender: TObject);
  64. var
  65.   Form: TCustomForm;
  66.   Msg: TWMKeyDown;
  67. begin
  68.   Form := Application.FindComponent('EditWindow_0') as TCustomForm;
  69.   if Assigned(Form) then
  70.   begin
  71.     Msg.CharCode := 0;
  72.     Msg.KeyData := $7F0001;
  73.     if Form.IsShortCut(Msg) then
  74.       ShowMessage('Accepted by editor as a shortcut');
  75.   end;
  76. end;
  77.  
  78. procedure TActionTrappingForm.ApplicationEventsActionExecute(
  79.   Action: TBasicAction; var Handled: Boolean);
  80. begin
  81.   if chkOn.Checked then
  82.   begin
  83.     if (Action is THintAction) and chkSkipHints.Checked then
  84.       Exit;
  85.     lstActions.Items.Add(Format('%s: %s', [Action.Name, Action.ClassName]));
  86.     lstActions.ItemIndex := lstActions.Items.Count - 1
  87.   end
  88. end;
  89.  
  90. procedure Register;
  91. begin
  92.   ActionTrappingForm := TActionTrappingForm.Create(Application)
  93. end;
  94.  
  95. initialization
  96. finalization
  97.   ActionTrappingForm.Free
  98. end.
  99.